﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSharp.Core.Authorization.Actors;
using TSharp.Core.Authorization.Resources;

namespace TSharp.Core.Authorization
{
    #region 注释
    /* ====================
     * 作者：wangyao
     * 创建时间：2013/5/24 11:30:51
     * ====================
     */
    #endregion
    /// <summary>
    /// 权限组件集成
    /// </summary>
    public class Integration : IAuthorityJudgerFactory
    {
        private static Integration _defaultIntegration = null;

        /// <summary>
        /// 默认集成
        /// </summary>
        public static Integration Default
        {
            get
            {
                if (_defaultIntegration == null)
                {
                     _defaultIntegration = new Integration();
                }
                return _defaultIntegration;
            }
            protected set
            {
                _defaultIntegration = value;
            }
        }

        /// <summary>
        /// 创建权限判断器
        /// </summary>
        public virtual IAuthorityJudger CreateJudger(string resourceCategoryKey)
        {
            ResourceCategory resourceCategory = ResourceCategoryRegistor.GetResourceCategoryByCode(resourceCategoryKey);

            return resourceCategory.AuthorityJudger;
        }
    }
}
